package com.bnc.menu.attendance;


import java.awt.event.ActionListener;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.*;

import com.bnc.dto.AttendDTO;
import com.bnc.manager.JDBCManager;
import com.bnc.props.GlobalData;

public class AttendWrite  {

	private JDBCManager jdbcManager;
	private PreparedStatement pstmt;
	
	public AttendWrite() {
		
		jdbcManager = JDBCManager.getInstance();
		String writer = GlobalData.memberDTO.getId();
		String name = GlobalData.memberDTO.getName();
		String date = Attendance.year+"."+Attendance.months+"."+Attendance.days;
		System.out.println(date);
		String time_in = Attendance.timein;
		String time_out ="";
		int info = Attendance.infoh;
		int fine = Attendance.fineh;
		String note = Attendance.noteh;
		
		
		String query = "INSERT INTO TBL_ATTEND " +
		   "VALUES( ?, ?, ?, ?, ?, ?, ?, ?, TBL_ATTEND_SEQ.nextval)";
		
		pstmt = jdbcManager.prepareStatement( query );
		
		try {
			pstmt.setString( 1, writer);
			pstmt.setString( 2, name);
			pstmt.setString( 3, date);
			pstmt.setString( 4, time_in);
			pstmt.setString( 5, time_out);
			pstmt.setInt( 6, info);
			pstmt.setInt( 7, fine);
			pstmt.setString( 8, note);
			pstmt.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
				try {
					if(pstmt != null)
					pstmt.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}		
				
				
		}
		
	}

}


